#include<sys/types.h>
#include<sys/stat.h>
#include<unistd.h>
#include<errno.h>
#include<stdlib.h>
#include<stdio.h>
#include<string.h>
#include<fcntl.h>

#define FIFO_SERVER "/tmp/myfifo"

int main(int argc , char* *argv){

	int fd;
	char wbuf[100];
 	int nwrite;
	
	fd = open(FIFO_SERVER , O_WRONLY|O_NONBLOCK , 0 );	
	
	if( argc == 1)
	{
		printf("Please send something \n");
		exit(-1);
	}	
	
	strcpy(wbuf , argv[1]);

	if( (nwrite=write(fd,wbuf,100))== -1 )
	{
		if(errno == EAGAIN)
			printf("The FIFO has not been read yet,Please try later\n");
	}
	else{
		printf("write %s to the FIFO \n",wbuf);
	}

	return 0;
}
